# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=node-libpg-query
_npmname=libpg-query
pkgver=13.1.2
# XXX: upstream does not use tags
_gitrev=f34989e21713a66938f559480230359b4a7d3c31
pkgrel=4
pkgdesc="The real PostgreSQL query parser for Node.js (experimental aport!)"
url="https://github.com/pyramation/libpg-query-node"
# riscv64: missing libpg_query
# x86: textrels
# armhf, armv7: blocked by libpg_query
arch="all !x86 !riscv64 !armhf !armv7"
license="MIT"
makedepends="libpg_query-dev nodejs-dev python3 yarn"
source="https://github.com/pyramation/libpg-query-node/archive/$_gitrev/$pkgname-$_gitrev.tar.gz
	gyp.patch
	package.patch
	bump-gyp.patch
	"
builddir="$srcdir/$_npmname-node-$_gitrev"

prepare() {
	default_prepare
	sed -Eix 's/"pg_query.h"/<pg_query.h>/' queryparser.cc src/*
}

build() {
	yarn install --frozen-lockfile --ignore-scripts --non-interactive
	yarn rebuild --release --verbose --nodedir=/usr/include/node
	yarn pack -f package.tgz
}

check() {
	yarn check
}

package() {
	tar -xf package.tgz \
		--strip-components=1 \
		--one-top-level="$pkgdir"/usr/lib/node_modules/$_npmname
}

sha512sums="
54f28409383783877f66a40375a663401c5fd2b8a6a73c059e6d286cb28332c489f1bf7ed67c6aaaab164a9443ad347f6bd7031dc4fdc5eac389c0bf40b16256  node-libpg-query-f34989e21713a66938f559480230359b4a7d3c31.tar.gz
54d3a540fc351a4e8530ad7455b25df666efef564699626da363531caf483785abea1bf1ba7b895c385af852dfffbd032c759d2cd73882bf77b8836aa9c9bbda  gyp.patch
d6656ddc5ee9b0c3365bb4f6f7deb0fea24cadf08450a09e0615a2c7c44f65ce6e2dcbddcf921af92bf9a3608d0134d1b2910b1af9e97b79a62600bab4f11f34  package.patch
aeff0d4fd3c0f0713607b98d682b1c46ee118586370cbb3f870ca67b90034cb075c2f443e2f21fa107f3c8a02e5ae905d9e836c64dfbde60068c6e249bb2123b  bump-gyp.patch
"
